package cheme.ProcessModel.Cmds;

import cheme.ProcessModel.Table.ISelectionModel;

public class SetModelSelectionCmd extends ChemeCommand
{
	private ISelectionModel model;
	private int newSelection = -1;
	private int oldSelection = -1;
	
	public SetModelSelectionCmd(ISelectionModel model, int newSelection)
	{
		super(model);
		
		super.setLabel("Set Model Selection");
		
		this.model = model;
		this.newSelection = newSelection;
	}
	
	@Override
	public void primExecute()
	{
		oldSelection = model.getSelection();
		model.setSelection(newSelection);
	}
	
	@Override
	public void primRedo()
	{
		model.setSelection(newSelection);
	}
	
	@Override
	public void primUndo()
	{
		model.setSelection(oldSelection);
	}
}
